package com.aaa.service.impl;

import com.aaa.dao.ChangeMapper;
import com.aaa.pojo.Change;
import com.aaa.service.ChangeService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Controller
public class ChangeServiceImpl implements ChangeService {
    @Autowired
    private ChangeMapper mapper;
    @Override
    public List<Change> selectAll() {
        return mapper.selectAll();
    }

    @Override
    public boolean insertChange(Change change) {
        return mapper.insertChange(change);
    }

    @Override
    public Change selectById(Integer c_id) {
        return mapper.selectById(c_id);
    }

    @Override
    public boolean updateChange(Change change) {
        return mapper.updateChange(change);
    }

    @Override
    public boolean deleteChange(Integer c_id) {
        return mapper.deleteChange(c_id);
    }

    @Override
    public PageInfo<Change> getAllUsersByPage(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);//这行是重点，表示从pageNum页开始，每页pageSize条数据
        List<Change> list = mapper.selectAll();
        PageInfo<Change> pageInfo = new PageInfo<Change>(list);
        return pageInfo;
    }
}
